package com.zhouxiaoxuan13.consumer.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 生鲜商品实体DTO
 * 用于Feign客户端调用时的数据传输
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class FreshProduct {

    private Long id;
    private String name;
    private String description;
    private String category;
    private String specifications;
    
    // 原价
    private BigDecimal originalPrice;
    
    // 库存数量
    private Integer stockQuantity = 0;
    
    // 保质期
    private LocalDate expiryDate;
    
    // 促销价格
    private BigDecimal promotionPrice;
    
    // 是否在促销中
    private Boolean isOnPromotion = false;
    
    // 关联的促销ID
    private Long promotionId;
    
    // 创建时间
    private LocalDateTime createdTime;
    
    // 更新时间
    private LocalDateTime updatedTime;
    
    /**
     * 获取当前有效价格
     */
    public BigDecimal getCurrentPrice() {
        return isOnPromotion != null && isOnPromotion && promotionPrice != null
            ? promotionPrice : originalPrice;
    }
}
